Function BGR2HSV(bgrvalue)
    If len(bgrvalue) < 6 Then
    bgrvalue = "000000"
    End If
    Dim b = left(right(bgrvalue, 6), 2)
    Dim g = left(right(bgrvalue, 4), 2)
    Dim r = right(bgrvalue, 2)
    r = CLng("0x"&r)
    g =    CLng("0x"&g)
    b = CLng("0x"&b)
    Dim max = r
    Dim min = r
    If max < g Then
    max = g
    End If
    If max < b Then
    max = b
    End If
    If min > g Then
    min = g
    End If
    If min > b Then
    min = b
    End If
    Dim h
    If r = max Then
    h = (g - b) / (max - min)
    End If
    If g = max Then
    h = 2 + (B - R) / (max - min)
    End If
    If b = max Then
    h = 4 + (R - G) / (max - min)
    End If
    h = h * 60
    If h < 0 Then
    h = h + 360
    End If
    h = Round(h)
    Dim s = (max - min) / max
    s = s * 100
    s = Round(s)
    Dim v = (max / 255) * 100
    v = Round(v)
    BGR2HSV = h & "." & s & "." & v
End Function